package 算法.leetcode.linked.list;

/**
 * @author lchenglong
 * @date 2020/12/14
 */
public class LinkListBase {
    public ListNode createTestData(int[] arr) {
        ListNode head = new ListNode(arr[0]);
        ListNode ptr = head;
        for (int i=1;i<arr.length;i++) {
            ListNode l1 = new ListNode(arr[i]);
            ptr.next = l1;
            ptr = ptr.next;
        }
        return head;
    }

    public void toString(ListNode node) {
        while (node!=null) {
            System.out.print(node.val);
            node = node.next;
            if (node != null) {
                System.out.print("-->");
            }
        }
        System.out.println();
    }

    public class ListNode {

        int val;

        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }
}
